package com.fis.vaadin.component;

import java.util.List;

import com.vaadin.ui.MenuBar;

public class FMenuBar extends MenuBar
{
	private final List<MenuItem> menuItems;
	
	public FMenuBar()
	{
		super();
		menuItems = super.getItems();
	}
	
	public void addItem(MenuBar.MenuItem item)
	{
		if (item != null)
		{
			menuItems.add(item);
			requestRepaint();
		}
	}
	
	public void addItemBefore(MenuBar.MenuItem addedItem, 
			MenuBar.MenuItem itemToAddBefore)
	{
		if (addedItem != null)
		{
			if (menuItems.contains(itemToAddBefore))
			{
				int index = menuItems.indexOf(itemToAddBefore);
				menuItems.add(index, addedItem);
				
			}
			else
			{
				menuItems.add(addedItem);
			}
			
			requestRepaint();
		}
	}
}
